package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentRepayService;
import com.heima.comment.service.CommentService;
import com.heima.comment.service.ManagementService;
import com.heima.model.comment.dto.ComDTO;
import com.heima.model.comment.dto.CommentLikeDTO;
import com.heima.model.comment.dto.CommentRepaySaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.comment.dto.ManagementDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "PC评论系统", tags = "PC评论系统")
@RequestMapping("/api/v1/comment")
public class ManagementController {
    @Autowired
    ManagementService managementService;
    @Autowired
    CommentRepayService commentRepayService;
    @Autowired
    CommentService commentService;
    @PostMapping("/list")
    @ApiOperation("查询评论列表")
    public ResponseResult list(@RequestBody ManagementDTO dto) {
        return managementService.findList(dto);
    }
    @PostMapping("/delete")
    @ApiOperation("删除列表")
    public ResponseResult delete(@RequestBody ComDTO dto) {
        return managementService.deleteList(dto);
    }

    @PostMapping("/add")
    @ApiOperation("添加回复")
    public ResponseResult add(@RequestBody @Validated CommentRepaySaveDTO dto) {
        return commentRepayService.saveCommentRepay(dto);
    }
    @PutMapping("/changeTop")
    @ApiOperation("评论置顶")
    public ResponseResult changeTop(@RequestBody ComDTO dto) {
        return managementService.changeTop(dto);
    }

    @PostMapping("/likings")
    @ApiOperation("评论点赞")
    public ResponseResult likings(@RequestBody @Validated CommentLikeDTO dto) {
        return commentService.like(dto);
    }
}
